package com.lzb.randomturntable.adapter;

import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.basic.ProviderMultiAdapter;
import com.lzb.basic.utils.SPUtil;
import com.lzb.basic.utils.TimeUtil;
import com.lzb.randomturntable.Content;
import com.lzb.randomturntable.R;
import com.lzb.randomturntable.bean.TurntableBean;

public class TurntableAdapter extends ProviderMultiAdapter<TurntableBean> {

    public TurntableAdapter() {
        addItemProvider(new TurntableProvider());
    }

    private class TurntableProvider extends BaseItemProvider<TurntableBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_turntable;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, TurntableBean bean) {
            baseViewHolder.setText(R.id.tvTurntableItemName, bean.getProblem());
            int pos = SPUtil.getInt(getContext(), Content.turntablePos, 0);
            if (pos == baseViewHolder.getBindingAdapterPosition()) {
                baseViewHolder.getView(R.id.tvTurntableItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.tvTurntableItemSel).setVisibility(View.GONE);
            }
        }
    }
}